package com.zyk.leetcode;

import java.util.ArrayList;
import java.util.List;

/**
 * @author zhangsan
 * @date 2021/4/15 10:35
 */
public class C145 {

    public List<Integer> postorderTraversal(TreeNode root) {
        List<Integer> ans = new ArrayList<>();
        postOrder(root, ans);
        return ans;
    }

    void postOrder(TreeNode root, List<Integer> res) {
        if(root == null) return;
        postOrder(root.left, res);
        postOrder(root.right, res);
        res.add(root.val);
    }


}
